<template>
	<view class="u-wrap">
		<view v-if="show">
			<view class="meituan">
				<view class="content" @click="tip_show = true">
					<view class="left">
						<view class="sum">
							￥
							<text class="num">{{cash_gift_yuan}}</text>
						</view>
						<!-- <view class="type">抵用券</view> -->
					</view>
					<view class="centre">
						<view class="title">商品专属礼金</view>
						<view class="valid-date">今日到期</view>
					</view>
					<view class="right">
						<view size="mini" class="immediate-use" :round="true" style="margin-left: 40rpx;">立即使用</view>
					</view>
				</view>
				<!-- <view class="tips">
					<view class="circle-left"></view>
					<view class="circle-right"></view>
					<view class="explain u-line-1">满8.1元可用、限最新版本客户端使用</view> -->
					<!-- <view class="rule u-line-1" @tap="xxx122"> -->
						<!-- <text>使用规则</text> -->
						<!-- <u-icon name="arrow-right" color="" :size="20" @click=""></u-icon> -->
					<!-- </view> -->
				<!-- </view> -->
			</view>
			<view class="taobao">
				<view class="title">
					<view class="left">
						<!-- <image class="buddha" src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1975388697,1068670603&fm=26&gp=0.jpg" mode="aspectFill"></image> -->
						<view class="store">{{ mall_name }}</view>
					</view>
					<!-- <view class="entrance">进店</view> -->
				</view>
				<view class="ticket">
					<view class="left">
						<image
							class="picture"
							:src="goods_image_url"
							mode="widthFix"
						></image>
						<view class="introduce">
							<view class="top">
								<view>
									最终成交价 <text class="big" style="margin-left: 10rpx;color: red;"> {{ (min_group_price_yuan - coupon_discount_yuan - cash_gift_yuan).toFixed(2) }}元</text>
								</view>
								原价￥
								<text>{{min_group_price_yuan}}元</text>
								<view>
								优惠券 {{coupon_discount_yuan}}元
						
								<!-- <view> -->
								<text style="margin-left: 30rpx;">专属礼金 {{cash_gift_yuan}}元</text>
								</view>
								<!-- </view> -->
							</view>
						
							<!-- <view class="type">最终成交价: </view> -->
							<!-- <view class="date u-line-1">2019.11.28-2020.1.24</view> -->
						</view>
					</view>
					<!-- <view class="right">
						<view class="use immediate-use" :round="true">去使用</view>
					</view> -->
				</view>
			</view>
		</view>
		<view v-else-if="!show">
			<u-modal v-model="content_show" :content="content"></u-modal>
		</view>
		<u-modal v-model="tip_show" :content="tip_content" :show-cancel-button=true @confirm="getDetail" @cancel="cancel"></u-modal>
	</view>
</template>

<script>
// var jWeixin = require('jweixin-module')  
// wx.config({
//   debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
//   appId: '', // 必填，公众号的唯一标识
//   timestamp: 123, // 必填，生成签名的时间戳
//   nonceStr: '', // 必填，生成签名的随机串
//   signature: '',// 必填，签名
//   jsApiList: [] // 必填，需要使用的JS接口列表
// });
// jWeixin.ready(function(){  
// 	// TODO  
// 	wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
// 	  wx.updateAppMessageShareData({ 
// 	    title: '多多券', // 分享标题
// 	    desc: '阿道夫', // 分享描述
// 	    link: 'https://aaa.com', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
// 	    imgUrl: '', // 分享图标
// 	    success: function () {
// 	      // 设置成功
// 	    }
// 	  })
// 	}); 
// });
export default {
	data() {
		return {
			goods_sign: '',
			mall_name: '',
			min_group_price_yuan: '',
			coupon_discount_yuan: '',
			goods_image_url: '',
			cash_gift_yuan: '',
			show: false,
			content_show: false,
			content: "请先浏览商品, 再来领取礼金",
			tip_show: false,
			tip_content: "每天只能领取三次礼金, 确认兑换吗",
			user_id: ''
		}
	},
	onLoad() {
		this.goods_sign = localStorage.getItem("goods_sign");
		this.mall_name = localStorage.getItem("mall_name");
		this.min_group_price_yuan = localStorage.getItem("min_group_price_yuan");
		this.coupon_discount_yuan = localStorage.getItem("coupon_discount_yuan");
		this.goods_image_url = localStorage.getItem("goods_image_url");
		this.cash_gift_yuan = localStorage.getItem("cash_gift_yuan");
		this.user_id = localStorage.getItem("user_id");
		if (this.goods_sign != null) {
			this.show = true;
		}
		this.content_show = !this.show;
	},
	methods: {
		getDetail() {
			var that = this;
			uni.request({
			  url: 'https://qianniu.bingdou.site/v1/pdd/cash_gift/promotion_url/generate', //仅为示例，并非真实的接口地址
			  method: 'POST',
			  data: {
				  'goods_sign': that.goods_sign,
				  'user_id': that.user_id,
				  'need_cash_gift': true
			  },
			  header: {
				'content-type': 'application/json' // 默认值
			  },
			  success (res) {
				  console.log(res);
				  // window.location.href=res.data.data.url;
			  }
			})
		},
		cancel() {
			this.tip_show = false;
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	height: 100%;
	background-color: rgb(244, 244, 244);
}
.u-wrap {
	padding: 24rpx;
}

.meituan {
	margin: 30rpx auto;
	background-color: #ffffff;
	width: 700rpx;
	// border: 10rpx;
	color: $u-type-warning;
	font-size: 28rpx;
	.content {
		display: flex;
		align-items: center;
		padding: 80rpx 20rpx;
		border: 10rpx;
		background-color: #fff5f4;
		.left {
			.sum {
				font-size: 32rpx;
				.num {
					font-size: 60rpx;
					font-weight: bold;
				}
			}
		}
		.centre {
			margin-left: 40rpx;
			.title {
				font-size: 32rpx;
				font-weight: bold;
				color: $u-main-color;
				margin-bottom: 20rpx;
			}
		}
		.right {
			margin-left: 30rpx;
			.immediate-use {
				padding: 0 20rpx;
				height: 50rpx;
				border-radius: 25rpx;
				line-height: 50rpx;
				background-color: $u-type-warning!important;
				color: #ffffff!important;
				font-size: 24rpx;
				border: none;
				word-break: keep-all;
			}
		}
	}
	.tips {
		padding: 0 20rpx;
		border: 10rpx;
		background-color: $u-type-info-light;
		position: relative;
		color: $u-tips-color;
		display: flex;
		justify-content: space-between;
		line-height: 60rpx;
		font-size: 24rpx;
		.circle-left,
		.circle-right {
			position: absolute;
			height: 36rpx;
			width: 18rpx;
			background-color: #f2f2f2;
		}

		.circle-right {
			border-radius: 40rpx 0 0 40rpx;
			right: 0;
			top: -18rpx;
		}

		.circle-left {
			border-radius: 0 40rpx 40rpx 0;
			left: 0;
			top: -18rpx;
		}
		.rule {
			font-size: 24rpx;
			display: flex;
			align-items: center;
			text {
				margin-right: 10rpx;
				flex: 1;
			}
		}
	}
}

.jingdong {
	margin-top: 40rpx;
	width: 700rpx;
	height: auto;
	background-color: #ffffff;
	display: flex;
	.left {
		padding: 0 30rpx;
		background-color: rgb(95, 148, 224); //rgb(94, 152, 225);
		text-align: center;
		font-size: 28rpx;
		color: #ffffff;
		.sum {
			margin-top: 50rpx;
			font-weight: bold;
			font-size: 32rpx;
			.num {
				font-size: 80rpx;
			}
		}
		.type {
			margin-bottom: 50rpx;
			font-size: 24rpx;
		}
	}
	.right {
		padding: 20rpx 20rpx 0;
		font-size: 28rpx;
		.top {
			border-bottom: 2rpx dashed $u-border-color;
			.title {
				margin-right: 60rpx;
				line-height: 40rpx;
				.tag {
					padding: 4rpx 20rpx;
					background-color: rgb(73, 154, 201);
					border-radius: 20rpx;
					color: #ffffff;
					font-weight: bold;
					font-size: 24rpx;
					margin-right: 10rpx;
				}
			}
			.bottom {
				display: flex;
				margin-top: 20rpx;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 10rpx;
				.date {
					font-size: 20rpx;
					flex: 1;
				}
				.immediate-use {
					height: auto;
					padding: 0 20rpx;
					font-size: 24rpx;
					border-radius: 40rpx;
					line-height: 40rpx;
					color: rgb(117, 142, 165);
					border: 2rpx solid rgb(117, 142, 165);
				}
			}
		}
		.tips {
			width: 100%;
			line-height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 24rpx;
			.transpond {
				margin-right: 10rpx;
			}
			.explain {
				display: flex;
				align-items: center;
			}
			.particulars {
				width: 30rpx;
				height: 30rpx;
				box-sizing: border-box;
				padding-top: 8rpx;
				border-radius: 50%;
				background-color: $u-type-info-disabled;
				text-align: center;
			}
		}
	}
}

.taobao {
	margin-top: 40rpx;
	width: 700rpx;
	background-color: white;
	padding: 30rpx 20rpx 20rpx;
	border-radius: 20rpx;
	.title {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 20rpx;
		font-size: 30rpx;
		.left {
			display: flex;
			align-items: center;
		}
		.store {
			font-weight: 500;
		}
		.buddha {
			width: 70rpx;
			height: 70rpx;
			border-radius: 10rpx;
			margin-right: 10rpx;
		}
		.entrance {
			color: $u-type-info;
			border: solid 2rpx $u-type-info;
			line-height: 48rpx;
			padding: 0 30rpx;
			background: none;
			border-radius: 15px;
		}
	}
	.ticket {
		display: flex;
		.left {
			width: 100%;
			padding: 30rpx 20rpx;
			background-color: rgb(255, 245, 244);
			border-radius: 20rpx;
			border-right: dashed 2rpx rgb(224, 215, 211);
			// display: flex;
			// .picture {
			// 	width: 100%;
			// 	border-radius: 20rpx;
			// }
			.introduce {
				margin-left: 10rpx;
				.top{
					color:$u-type-warning;
					font-size: 28rpx;
					.big{
						font-size: 60rpx;
						font-weight: bold;
						margin-right: 10rpx;
					}
				}
				.type{
					font-size: 28rpx;
					color: $u-type-info-dark;
				}
				.date{
					margin-top: 10rpx;
					font-size: 20rpx;
					color: $u-type-info-dark;
				}
			}
		}
		.right {
			width: 30%;
			padding: 40rpx 20rpx;
			background-color: rgb(255, 245, 244);
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			.use{
				height: auto;
				padding: 0 20rpx;
				font-size: 24rpx;
				border-radius: 40rpx;
				color: #ffffff!important;
				background-color: $u-type-warning!important;
				line-height: 40rpx;
				color: rgb(117, 142, 165);
				margin-left: 20rpx;
			}
		}
	}
}
</style>